

<style>
  .layui-form-label{
    width: 120px;
  }
</style>


<div style="margin: 5% 5%;">
<form class="layui-form" action=""  lay-filter="example">

  <div class="layui-form-item  layui-col-xs12" style="display: none" >
    <div class="layui-inline ">
      <div class="layui-input-inline">
        <input type="text" name="stationId" autocomplete="off" class="layui-input" disabled="disabled" value="">
      </div>
    </div>
  </div>
  <div class="layui-form-item  layui-col-xs12">
    <div class="layui-inline ">
      <label class="layui-form-label">站点编号:</label>
      <div class="layui-input-inline">
        <input type="text" name="stationbh"  autocomplete="off" class="layui-input" disabled="disabled" >
      </div>
    </div>
  </div>
  <div class="layui-form-item layui-col-xs12">
    <div class="layui-inline layui-col-xs12">
      <label class="layui-form-label">站点名称:</label>
      <div class="layui-input-inline">
        <input type="text" name="stationname" autocomplete="off" class="layui-input" disabled="disabled" >
      </div>
    </div>
  </div>

  <div class="layui-form-item layui-col-xs12">
    <div class="layui-inline">
      <label class="layui-form-label">站点类型: </label>
      <div class="layui-input-inline">
        <select name="stationtypename" disabled="disabled" >
        </select>
      </div>
    </div>
  </div>
  <div class="layui-form-item layui-col-xs12">
    <div class="layui-inline">
      <label class="layui-form-label">所属区域:</label>
      <div class="layui-input-inline">
        <input type="text" name="quyu"  autocomplete="off" class="layui-input" disabled="disabled" >
      </div>
    </div>
  </div>

  <div class="layui-form-item layui-col-xs12">
    <div class="layui-inline">
      <label class="layui-form-label">详细地址:</label>
      <div class="layui-input-inline">
        <input type="text" name="city"  autocomplete="off" class="layui-input" disabled="disabled" >
      </div>
    </div>

  </div>
  <div class="layui-form-item layui-col-xs12">
    <div class="layui-inline">
      <label class="layui-form-label">联系电话:<span style="color: red">*</span></label>
      <div class="layui-input-inline">
        <input type="tel" name="stationPhone" lay-verify="required|phone" autocomplete="off" class="layui-input" onkeyup="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')"  >
      </div>
    </div>
  </div>

  <div class="layui-form-item layui-col-xs12">
    <div class="layui-inline">
      <label class="layui-form-label">点播服务器IP:</label>
      <div class="layui-input-inline">
        <input type="text" name="IPLocation" autocomplete="off" class="layui-input" disabled="disabled" >
      </div>
    </div>
  </div>
  <div class="layui-form-item layui-col-xs12">
    <div class="layui-inline">
      <label class="layui-form-label">VNP地址:</label>
      <div class="layui-input-inline">
        <input type="text" name="vpn" autocomplete="off" class="layui-input" disabled="disabled">
      </div>
    </div>
  </div>

  <div class="layui-form-item layui-col-xs12">
    <div class="layui-inline">
      <label class="layui-form-label">点钟包IP地址:</label>
      <div class="layui-input-inline">
        <input type="text" name="dzbip" autocomplete="off" class="layui-input" disabled="disabled">
      </div>
    </div>
  </div>
  <div class="layui-form-item layui-col-xs12">
    <div class="layui-inline">
      <label class="layui-form-label">最大终端数:</label>
      <div class="layui-input-inline">
        <input type="text" name="stationMaximumNumberOfTerminals" autocomplete="off" class="layui-input" disabled="disabled">
      </div>
    </div>
  </div>

    <div class="layui-form-item layui-col-xs12">
        <div class="layui-inline">
            <label class="layui-form-label">站点状态:</label>
            <div class="layui-input-inline">
                <select name="status" disabled="disabled">
                    <option value="启用">启用</option>
                  <option value="禁用">禁用</option>
                </select>
            </div>
        </div>
    </div>
  <div class="layui-form-item layui-col-xs12">
        <div class="layui-inline">
            <label class="layui-form-label">是否开启OSS:</label>
            <div class="layui-input-inline">
                <select name="stationOss" >
                    <option value="开启" >开启</option>
                    <option value="关闭" >关闭</option>
                </select>
            </div>
        </div>
    </div>

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">修改</button>
    </div>
  </div>
</form>
</div>
<script src="/js/layui/layui.all.js"></script>
<script src="/admin/js/token.js"></script>

<script>
  var $ = layui.$;
  var local_store = layui.data("local_store");
  var local = local_store.token;
  var json=GetRequest();
  $.ajax({
    type:"get",
    url:"/admin/station/query/stationLoginQuanxXian?stationId="+json.id,
    dataType: "json",
    contentType:"application/json;charset=utf-8",
    beforeSend: function(request) {
      request.setRequestHeader("token", local);
    },
    success:function (res) {
      if(res.code==500){
        alert("权限不足")
        location="../../admin/main.html";
        return
      }else{

          var form = layui.form
                  ,layer = layui.layer
                  ,layedit = layui.layedit
                  ,laydate = layui.laydate;
          // form.render()

          $.ajax({
            type:"get",
            url:"/admin/station/queryByIdstationdetails",

            data:{
              "stationId":json.id
            },
            success:function (res) {
              form.val('example', {
                "stationbh": res.data.station_bh, // "name": "value"
                "stationname":res.data.station_name,
                "stationtypename":res.data.station_type,
                "quyu":res.data.station_quyu,
                "city":res.data.detailed_address,
                "stationPhone":res.data.station_phone,
                "IPLocation":res.data.station_local_server_ip,
                "vpn":res.data.station_vpn,
                "dzbip":res.data.station_bh,

                "stationMaximumNumberOfTerminals":res.data.station_maximum_number_of_terminals,
                "status":res.data.station_type_status,
                "stationOss":res.data.station_oss
              })
            }
          });

          $.ajax({
            type: 'GET',
            url: '/admin/station-type/query/AllStationType',
            success: function (data) {
              $.each(data.data, function (key, val) {
                var option1 = $("<option>").val(val.stationTypeId).text(val.stationTypeName);
                $("select[name='stationtypename']").append(option1);
              });
              layui.form.render('select');
            }
          });
          //监听提交
          form.on('submit(demo1)', function(data){
            $.ajax({
              url: "/admin/station/updateByIdStation",
              type: 'PUT',
              dataType: "JSON",
              contentType:"application/json;charset=utf-8",
              data:JSON.stringify(data.field),
              // beforeSend: function () {
              //   this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']});
              // },
              success: function (res) {
                // console.log(res)
                if (res.code== 500) {
                  layer.msg("修改失败", {icon: 5,time: 1000});//失败的表情
                  return;
                } else if (res.code == 200) {
                  layer.msg("修改成功", {
                    icon: 6,//成功的表情
                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                  }, function () {
                    location.reload();
                  });
                }
              },
              error: function () {
                layer.msg('网络原因修改失败', {
                  icon: 2,time: 1000
                })
              },
              complete: function () {
                layer.close(this.layerIndex);
              }

            })
            return false; //阻止表单跳转
          })
          ;
        function GetRequest() {
          var url = decodeURI(location.search); //获取url中"?"符后的字串
          var theRequest = new Object();
          if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for(var i = 0; i < strs.length; i ++) {
              theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
            }
          }
          return theRequest;
        }


        $("input[name='stationId']").attr("value",json.id)
      }
    }
  });


</script>